home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
os2
/
radius_2.zip
/
pcrypt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-03
|
2KB
|
83 lines
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/file.h>
#include <netinet/in.h>
#include <stdio.h>
#include <netdb.h>
#include <fcntl.h>
#include <pwd.h>
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <process.h>
#include <sys/wait.h>
#include <io.h>
#if !defined(NOSHADOW)
/*#include <shadow.h>*/
#endif /* !NOSHADOW */
#include "radius.h"
int
main(argc, argv)
int argc;
char **argv;
{
struct passwd *pwd;
struct passwd *getpwnam();
char *encpw;
char *crypt();
char *encrypted_pass;
char *name;
char *passwd;
name = argv[1];
passwd = argv[2];
#if !defined(NOSHADOW)
#if defined(M_UNIX)
struct passwd *spwd;
#else
struct passwd *spwd;
#endif
#endif /* !NOSHADOW */
encpw = NULL;
/* Get encrypted password from password file */
if((pwd = getpwnam(name)) == NULL) {
return(-1);
}
encrypted_pass = pwd->pw_passwd;
fprintf(stderr,"Encpw1:%s",encrypted_pass);
#if !defined(NOSHADOW)
if(strcmp(pwd->pw_passwd, "x") == 0) {
/* if((spwd = getspnam(name)) == NULL) {
return(-1);
}
*/
#if defined(M_UNIX)
encrypted_pass = spwd->pw_passwd;
#else
encrypted_pass = spwd->pw_passwd;
#endif /* M_UNIX */
}
#endif /* !NOSHADOW */
/* Run encryption algorythm */
encpw = crypt(passwd, encrypted_pass);
fprintf(stderr,"Encpw2:%s",encpw);
/* Check it */
if(strcmp(encpw, encrypted_pass)) {
return(-1);
}
return(0);
}